<template>
	<view>
		<view class="status_bar"></view>
		<view class="top" >
					 <view style="font-weight: bold;padding-left: 10rpx;" @click="toBack">取消</view>
					 
					 <text style="text-align: center;font-weight: bold;padding-left: 220rpx;">添加伙伴</text>
					 <!-- <u-icon size="50rpx" style="float: right;" name="plus" @click="addEvent"></u-icon> -->
		</view>
		<view style="background-color: #ffeabe;border-radius: 40rpx;margin: 30rpx 20rpx 30rpx 20rpx;padding: 30rpx;">
			<view style="padding-left: 20rpx;margin-bottom: 20rpx;">填写验证消息</view>
			<textarea :value="content"  style="background-color: #fff4e2;margin: auto;width: 90%;border-radius: 20rpx;padding: 20rpx 20rpx 20rpx 20rpx;height: 200rpx;"></textarea>
		</view>
		<u-button shape="circle" style="width: 90%;background-color: #ffdf80;margin-top:500rpx" @click="send">发送申请</u-button>
	</view>
</template>

<script>
	export default {
		onLoad(option){
			console.log(option)
			this.myId=option.myId
			this.friendId=option.friendId
			this.$H.get('user/'+option.myId).then(res=>{
				console.log(res)
				 this.username=res.data.username
				 this.content=this.content+this.username+"，想和你成为搭子。"
				
			})
			},
		
		data() {
			return {
				username: "",
				content: "你好，我是",
				myId:"",
				friendId:""
				
				
			};
		},
		methods:{
			toBack(){
				uni.navigateBack()
			},
			send(){
				this.$H.get('friends/requestTobeFriend?userId='+this.myId+'&friendId='+this.friendId+'&des='+this.content).then(res=>{
					if(res.code==200){
						uni.showToast({
							title:"申请成功",
							icon:"success"
						})
						setTimeout(function () {
						                        uni.navigateBack()
						                    }, 2000);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.status_bar {
	        height: var(--status-bar-height);
	        width: 100%;
	    }
	.top{
		display: flex;
		width: 100%;
		box-sizing: border-box;
		//justify-content: space-between;
		
	    align-items: center;
		height: 200rpx;
		padding: 0 30rpx;
		background: linear-gradient(to right, #ffdf80,#fff4de);
	}
</style>
